﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Vue_AspNetCore_Project.Models;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;


namespace Vue_AspNetCore_Project.Data
{
    public class ApplicationDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, int>
    {
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {

            optionsBuilder.EnableSensitiveDataLogging();
        }
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
        {

        }
        public DbSet<Order> Orders { get; set; }
 

        public DbSet<Company> Companies { get; set; }

 

        public DbSet<Invoice> Invoices { get; set; }
 
        public DbSet<Code> Codes { get; set; }
 

        public DbSet<Feedback> Feedbacks { get; set; }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            builder.Entity<Code>().ToTable("T_Code");

            var companytbl = builder.Entity<Company>().ToTable("T_Company");

            var ordertbl = builder.Entity<Order>().ToTable("T_Order");
            ordertbl.HasIndex(b => b.UserId);

            builder.Entity<Invoice>().ToTable("T_Invoice").HasIndex(b => b.UserId); ;

            builder.Entity<Feedback>().ToTable("T_Feedback").HasIndex(b => b.UserId); ; ;

        }
    }
}